<template>
	<view>
		<navtop :back='true' title="提现"></navtop>
		<view class="htop">
			<view class="p">可提现金额（元）</view>
			<view class="rmb">{{user.rmb}}</view>
		</view>
		<view class="list">
			<view class="li">
				<view class="name">收款人姓名</view>
				<input v-model="post.txname" placeholder="请填写收款人姓名"/>
			</view>
			<view class="li">
				<view class="name">支付宝账号</view>
				<input v-model="post.txaccount" placeholder="请填写支付宝账号"/>
			</view>
			<view class="li">
				<view class="name">提现金额</view>
				<input v-model="post.rmb" placeholder="请填写提现金额"/>
			</view>
		</view>
		<view class="btn" @click="get_btn()">确定提现</view>
		<view class="hint">
			<view class="title">温馨提示：</view>
			<view class="p">1、为了保证您的利益，请准确填写提现账号及姓名，若信息填写有误导致提现异常与平台无关;</view>
			<view class="p">2、提现将在7个工作日内统一处理;</view>
			<view class="p">3、提现遇到任何问题请联系客服;</view>
		</view>
	</view>
</template>

<script>
    let that = null;
    export default {
        data() {
            return {
				user: {
					rmb: '0.00',
					min_rmb: 0,
					max_rmb: 0,
				},
				post: {
					txname: '',
					txaccount: '',
					rmb: ''
				}
            }
        },
        mounted() {
            that = this;
			that.get_data();
        },
        methods: {
			get_link(url){
				uni.navigateTo({
					url: '../'+url
				});
			},
			get_data(){
				that.http.get_curl('withdraw/index',{},function(res){
					that.load = false;
					if(res.code == 1){
						that.user = res.data.user;
						that.post = res.data.post;
					}
				});
			},
			get_btn(){
				if(!that.post.txname){
					uni.showToast({
						title: "请填写收款人姓名",
						icon: "none"
					});
					return;
				}
				if(!that.post.txaccount){
					uni.showToast({
						title: "请填写收款账号",
						icon: "none"
					});
					return;
				}
				if(that.post.rmb > that.user.rmb){
					uni.showToast({
						title: "余额不足",
						icon: "none"
					});
					return;
				}
				if(that.post.rmb < that.user.min_rmb){
					uni.showToast({
						title: "提现金额不能小于"+that.user.min_rmb+"元",
						icon: "none"
					});
					return;
				}
				if(that.post.rmb > that.user.max_rmb){
					uni.showToast({
						title: "提现金额不能大于"+that.user.max_rmb+"元",
						icon: "none"
					});
					return;
				}
				that.http.get_curl('withdraw/save',that.post,function(res){
					if(res.code == 1){
						uni.showToast({
							title: res.msg,
							icon: "none"
						});
						uni.navigateBack();
					}
				});
			}
        }
    }
</script>

<style lang="scss">
	.htop{
		background: #fff;padding: 32rpx;text-align: center;
		.p{font-size: 28rpx;color:#999;}
		.rmb{font-size: 50rpx;color: #333;padding-top: 10rpx;}
	}
	.list{width: calc(100% - 104rpx);margin: 30rpx auto;border-radius: 10rpx;padding: 0 32rpx;background: #fff;
		.li{width: 100%;height: 100rpx;display: flex;justify-content: space-between;align-items: center;border-bottom: 1rpx solid #f5f5f5;
			.name{font-size: 30rpx;color: #333;width: 260rpx;}
			input{font-size: 28rpx;text-align: right;}
		}
	}
	.btn{width: 70%;height: 80rpx;line-height: 80rpx;font-size: 30rpx;color: #fff;text-align: center;background: linear-gradient(270deg, #fcae3a, #f15d25);border-radius: 80rpx;margin: 30rpx auto;}
	.hint{padding: 0 32rpx;
		.title{font-size: 30rpx;font-weight: 600;color: #333;padding-bottom: 10rpx;}
		.p{font-size: 26rpx;color: #666;}
	}
</style>